//快乐数
public class IsHappy {
    public int powNum(int num){
        int ret = 0;
        while (num > 0){
            ret += Math.pow(num % 10, 2);
            num /= 10;
        }

        return ret;
    }
    public boolean code(int n){
        int slow = powNum(n);
        int fast = powNum(slow);

        while (slow != fast){
            slow = powNum(slow);
            fast = powNum(powNum(fast));
        }

        if (slow == 1){
            return true;
        }

        return false;
    }

    public static void main(String[] args) {

    }
}
